package com.gitee.huxing.courese.core;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.courese.core
 * @ClassName: KmqProducer
 * @Author: huxing
 * @DateTime: 2021-11-07 4:08 下午
 */
public class KmqProducer {

    /** 构造器 **/
    private KmqBroker broker;

    public KmqProducer(KmqBroker broker) {
        this.broker = broker;
    }

    public boolean send(String topic, KmqMessage message){
        Kmq kmq = this.broker.findKmq(topic);
        if (null == kmq) throw new RuntimeException("Topic[" + topic + "] doesn't exist.");
        return kmq.send(message);
    }
}
